import request from '@/utils/request'
import requestFile from '@/utils/request-file'
import { formatDateByFmt } from '@/utils/util'

const prefixUrl = 'web/financial_summary/'

// 合同列表分页
export function contract_list(params) {
  return request({
    url: prefixUrl + 'contract_list',
    method: 'get',
    params: params
  })
}

// 销售单组别列表分页
export function groupList(params) {
  return request({
    url: prefixUrl + 'group_list',
    method: 'get',
    params: params
  })
}

// 列表
export function list(params) {
  return request({
    url: prefixUrl + 'list',
    method: 'get',
    params: params
  })
}

export function receiveContract(params) {
  return request({
    url: prefixUrl + 'receiveContract',
    method: 'post',
    params: params
  })
}

export function fill(params) {
  return request({
    url: prefixUrl + 'fill',
    method: 'post',
    params: params
  })
}

export function remind(params) {
  return request({
    url: prefixUrl + 'remind',
    method: 'post',
    params: params
  })
}

export function updateDate(params) {
  return request({
    url: prefixUrl + 'updateDate',
    method: 'post',
    params: params
  })
}

// 导出excel
export function exportExcel(params) {
  return requestFile({
    url: prefixUrl + '/export',
    method: 'get',
    params,
    fileName: '销售统计' + (formatDateByFmt(new Date(), 'yyyyMMddhhmmss') + Math.floor(Math.random() * (
      1000000 -
      1) + 1)) + '.xlsx'
  })
}
